#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


class Solution {
public:
    /**
     * lru design
     * @param operators int整型vector<vector<>> the ops
     * @param k int整型 the k
     * @return int整型vector
     */
    vector<int> LRU(vector<vector<int> >& operators, int k) {
        // write code here
        vector<int> fre;
        vector<int> key;
        vector<int> res;
        for(int i = 0; i < operators.size(); i++){
            if(operators[i][0] == 1){
                set(operators[i][1], operators[i][2], fre, key, k);
            }
            if(operators[i][0] == 2)
                get(operators[i][1], fre, key, res);
        }
        return res;
    }
    
    void set(int a, int b, vector<int> &r, vector<int> &key, int k){
        if(r.size() < k){
            key.push_back(a);
            r.push_back(b);
        }
        else{
            key.erase(key.begin());
            r.erase(r.begin());
            key.push_back(a);
            r.push_back(b);
        }
    }
      
    void get(int a, vector<int> &r, vector<int> &key ,vector<int> &result){
        int t = -1;
        for(int i = 0; i < key.size(); i++){
            if(a == key[i]){
                t = i;
                break;  
            }
        }
        if(t == -1){
            result.push_back(-1);
        }
        else{
            int t1, t2;
            t1 = key[t];
            t2 = r[t];
            key.erase(key.begin() + t);
            r.erase(r.begin() + t);
            key.push_back(t1);
            r.push_back(t2);
            result.push_back(t2);
        }
    }
};

static const auto ios = [](){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    return nullptr;
}();

int main(){
	vector<vector<int>> v={{1,1,1},{1,2,2},{1,3,2},{2,1},{1,4,4},{2,2}};
    Solution s;
   auto v1=s.LRU(v,3);
    for(auto x:v1){
        cout << x <<" ";
    }cout <<endl;
    return 0;
}
